package Thread;

class Student {
    volatile static Student s;

    public static Student getS() {
        return s;
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            s = new Student();
        });
        Thread t2 = new Thread(()->{
            if(s != null) {
                s.getClass();
            }
        });

    }
}

public class ThreadDemo15 {
   volatile   static boolean flog = false;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while (!flog) {
                //什么都不打印
            }
            //循环执行结束
            System.out.println("循环执行结束");
        });

        t1.start();

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        flog = true;
        System.out.println("flog改为true");
    }
}
